package com.firefly.dao.assembler.mc;

import com.firefly.dao.dao.mc.po.McMenuPo;
import com.firefly.dao.dto.mc.McMenuDto;
import com.firefly.dao.vo.mc.McMenuTreeVo;
import com.firefly.dao.vo.mc.McMenuVo;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @description:
 * @author: lzg(萤火科技 ： 854378082 @ qq.com)
 * @date: 2023/1/31
 **/
@Component
public class McMenuAssembler {
    public List<McMenuTreeVo> getTreeList(List<McMenuPo> list) {
        List<McMenuTreeVo> result = new ArrayList<>();
        list.forEach(item -> {
            McMenuTreeVo tmp = new McMenuTreeVo();
            tmp.setId(item.getId());
            tmp.setParentId(item.getParentId());
            tmp.setName(item.getName());
            tmp.setUrl(item.getUrl());
            result.add(tmp);
        });
        return result;
    }

    public McMenuVo getVo(McMenuPo entity) {
        McMenuVo detail = new McMenuVo();
        detail.setId(entity.getId());
        detail.setParentId(entity.getParentId());
        detail.setName(entity.getName());
        detail.setUrl(entity.getUrl());
        return detail;
    }

    public McMenuPo getPo(McMenuDto detail){
        McMenuPo entity = new McMenuPo();
        entity.setId(detail.getId());
        entity.setParentId(detail.getParentId());
        entity.setName(detail.getName());
        entity.setUrl(detail.getUrl());
        return entity;
    }
}
